package com.zggk.iroad.Distribution.distributionlist;

import android.content.Context;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.lzy.okgo.model.Response;
import com.zggk.iroad.api.MyAppliCation;
import com.zggk.iroad.api.Urls;
import com.zggk.iroad.diease.dieaselist.DistriListBean;
import com.zggk.iroad.log.LogSuccessBean;
import com.zggk.iroad.mvp.BasePresenterImpl;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class DistributionListPresenter extends BasePresenterImpl<DistributionListContract.View> implements DistributionListContract.Presenter{
    @Override
    public void getDH() {
        OkGo.<String>get(Urls.YNIP + "QueryRwpfYN")
                .params("gydwid", MyAppliCation.spUtils.getString("GydwId"))
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        DhBean videoVos = JSON.parseObject(response.body(), DhBean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getDhs(videoVos);
                        }
                    }
                });
    }
    @Override
    public void testinfo(String LXID,String BHLX, String DATAID,String ACTION) {
        OkGo.<String>get(Urls.YNIP + "QueryRwpfListYN")
                .params("starttime", "")
                .params("endtime", "")
                .params("lxcode", LXID)
                .params("bhlx", BHLX)
                .params("gydwid", MyAppliCation.spUtils.getString("GydwId"))
                .params("listtype", "0")
                .params("DATAID", DATAID)
                .params("ACTION", ACTION)
                .params("PAGESIZE", "20")
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        DistriListBean videoVos = JSON.parseObject(response.body(), DistriListBean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getData(videoVos);
                        }
                    }
                });
    }
    @Override
    public void getPaifa(String json,String BHGUID) {
        OkGo.<String>get(Urls.YNIP + "MobileRwpfYN")
                .params("json", json)
                .params("BHGUID", BHGUID)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        LogSuccessBean videoVos = JSON.parseObject(response.body(), LogSuccessBean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getPaifas(videoVos);
                        }
                    }
                });
    }
    @Override
    public void getBcz(String bhguid,String bhzt,String user) {
        OkGo.<String>get(Urls.YNIP + "MobileBhcz")
                .params("bhguid", bhguid)
                .params("bhzt", bhzt)
                .params("user", user)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        LogSuccessBean videoVos = JSON.parseObject(response.body(), LogSuccessBean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getBczs(videoVos);
                        }
                    }
                });
    }
    @Override
    public void getNr(String bhguid,String bhzt,String user) {
        OkGo.<String>get(Urls.YNIP + "MobileBhcz")
                .params("bhguid", bhguid)
                .params("bhzt", bhzt)
                .params("user", user)
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(Response<String> response) {
                        if (mView == null)
                            return;
                        LogSuccessBean videoVos = JSON.parseObject(response.body(), LogSuccessBean.class);
                        if (videoVos.getState().equals("1")){
                            mView.getNr(videoVos);
                        }
                    }
                });
    }
}
